import time
import random
import pyautogui

x0 = 744
y0 = 227
w = 42
h = 42

with open("coordinates.txt", "r") as f:
    lines = f.readlines()

for line in lines:
    if line.startswith("Rectangle:"):
        coords = eval(line.replace("Rectangle:", "").strip())
        (x1, y1), (x2, y2) = coords
        start_x = x0 + (x1 - 1) * w + w // 2
        start_y = y0 + (y1 - 1) * h + h // 2
        end_x = x0 + x2 * w - w // 2
        end_y = y0 + y2 * h - h // 2
        pyautogui.moveTo(start_x, start_y, duration=0.1)
        pyautogui.dragTo(end_x, end_y, duration=0.1, button='left')
        interval = random.uniform(0.1, 0.3)
        time.sleep(interval)
